package ThreadDemo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-09-06
 * Time: 10:31
 */

class MyThread extends Thread {
    @Override
    public void run() {
        while (true) {
            System.out.println("I am is new Thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class ThreadDemo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new MyThread();
        t.start();//创建新线程，并执行run方法
        while(true){
            System.out.println("I am is main Thread");
            Thread.sleep(1000);
        }
    }
}
